#ifndef FOUNDATION_PROTOCOL_XCOMPROCESS_H
#define FOUNDATION_PROTOCOL_XCOMPROCESS_H
#include <map>
#include <memory>
#include <stack>
#include <tuple>
#include "xcom_node.h"
#include <dataitem.h>
#include <functional>

namespace protocol {

using ParseRecv = std::function<libxcom::RECV_RESULT(uint8_t *, int32_t)>;
using XComSend =
	std::function<bool(const libxcom::CmdValue &, const ParseRecv &)>;
class XComListener {
public:
	std::function<libxcom::CmdValue(const libxcom::CmdValue &cmd)>
		xComSendBuffer;
};

class XComProcess {
public:
	XComProcess(
		const std::shared_ptr<XComNode> &xcomNode, const std::string &addr);
	~XComProcess();
	bool IsReadFlow(const std::string &funcId);
	bool Process(const std::string &funcId, XComSend sendFunc,
		const std::vector<libxcom::OpValue> &params = {}, float ratio = 1);
	libxcom::OpValue GetResult(const std::string &var);

private:
	std::shared_ptr<XComNode> xcomNode_ = nullptr;
	libxcom::DataItem dataItem_;
};
} // namespace protocol

#endif // FOUNDATION_PROTOCOL_XCOMPROCESS_H